import request from '@/common/request/request.js'
import config from '@/common/config/config.js';
import md5 from 'js-md5'
import dayjs from 'dayjs'
const http = config.env

// 客服加密
export const getAesData = data => {
	return request({
		url: http.baseUrl + '/echat/aesEncryption',
		method: 'POST',
		data: data,
	})
}

// 新saas获取验证码
export const newSendCode = data => {
	let date = dayjs().format('YYYYMMDD')
	let saasToken = date + 'MNAc1qMEyQXauIVckovoh5gklhQnziyZ' + 2
	saasToken = md5(saasToken)
	return request({
		url: http.saasUrl + `/saasapi/sms/newSendYzm`,
		method: 'POST',
		data: {
			...data,
			signCode:9
		},
		header: {
			'develop':'prod',
			'content-type': 'application/x-www-form-urlencoded',
			'saasToken':saasToken
		}
	})
}

// 登录
export const login = data => {
	return request({
		url: http.baseUrl + '/oauth/login',
		method: 'POST',
		data: data,
	})
}

// 注册
export const register = data => {
	return request({
		url: http.baseUrl + '/oauth/register',
		method: 'POST',
		data: data,
	})
}

// 获取最后的app版本号 driveType = 1安卓 2 ios
export const lastVersion = (driveType) => {
	return request({
		url: http.baseUrl + '/common/lastVersion/' + driveType,
		method: 'GET',
	})
}

// 获取系统配置
export const sysConfig = (key) => {
	return request({
		url: http.baseUrl + '/common/config/' + key,
		method: 'GET',
	})
}

// 获取混合支付比例
export const findMixedPayment = () => {
	return request({
		url: http.baseUrl + '/appConfig/findMixedPayment',
		method: 'GET',
	})
}

// 更新用户信息
export const changeUserinfo = (data) => {
	return request({
		url: http.baseUrl + '/user/setInfo',
		method: 'POST',
		data
	})
}

// 开通数据中心
export const openDataCenterAjax = (data) => {
	return request({
		url: http.baseUrl + '/api/data/centre/addDataCentre',
		method: 'POST',
		data
	})
}


// 修改支付密码
export const payCipher = (data) => {
	return request({
		url: http.baseUrl + '/customer/payCipher',
		method: 'POST',
		data
	})
}

// 地区列表
export const citiesList = (data) => {
	return request({
		url: http.baseUrl + '/baseData/cities',
		method: 'GET',
		data
	})
}
